#!/usr/bin/python
# coding=utf-8

import plotly.plotly
import pandas as pd
import plotly.figure_factory as ff
from source.SourceCode import SourceCode


class Violin:
    def __init__(self):
        print "violin图表生成类！"

    def makeViolin(self, score, group, title, name):
        data = pd.DataFrame(dict(Score=score, Group=group))
        fig = ff.create_violin(data, data_header='Score', group_header='Group', height=700, width=1200, title=title)
        plotly.offline.plot(fig, filename=name + ".html")


if __name__ == "__main__":
    sss = Violin()
    xx = []
    yy = []
    bbb = [x * 10 for x in range(1, 11)]
    print bbb
    for i in bbb:
        print i
        c = SourceCode.read_file_line("/Users/fv/IdeaProjects/student_middle/long/" + str(i) + ".log")
        yy.extend(c)
        print c
        for j in c:
            xx.append(i)
    print xx
    sss.makeViolin(yy, xx, "name", "api")
